package com.hualan.domain;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 资讯公告表，用于存储用户通知展示信息
 * @TableName publicity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Publicity implements Serializable {
    /**
     * 编号，主键自增
     */
    private Long id;

    /**
     * 公告名
     */
    private String name;

    /**
     * 公告内容
     */
    private String publicitytext;

    /**
     * 发布时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createtime;

    private static final long serialVersionUID = 1L;

    public Publicity(Long id, String name, String publicitytext) {
        this.id = id;
        this.name = name;
        this.publicitytext = publicitytext;
    }

    public Publicity(String name, String publicitytext) {
        this.name = name;
        this.publicitytext = publicitytext;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Publicity other = (Publicity) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getPublicitytext() == null ? other.getPublicitytext() == null : this.getPublicitytext().equals(other.getPublicitytext()))
            && (this.getCreatetime() == null ? other.getCreatetime() == null : this.getCreatetime().equals(other.getCreatetime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getPublicitytext() == null) ? 0 : getPublicitytext().hashCode());
        result = prime * result + ((getCreatetime() == null) ? 0 : getCreatetime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", name=").append(name);
        sb.append(", publicitytext=").append(publicitytext);
        sb.append(", createtime=").append(createtime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}